'''
1.if判断语句
语法:if 条件:
      条件成立执行的代码
    else:
      条件不成立执行的代码
2.if---elif---else多重判断语句
语法:if 条件1:
       条件1成立执行的代码
    elif 条件2:
        条件2成立执行的代码
    else：
        以上条件都不成立执行的代码
*随机数
1.导入random模块
2.变量 = random.randint(开始,结束)
语法:import random
    变量 = random.randint(开始,结束)
'''
import random
computer = random.randint(0,2)
i = 1
x=0
y=0
n=5
while i <= n:
    print(f'\t第{i}局')
    print(f"\t{x}:{y}")
    player = input("请出拳：")
    if (player == "布" and computer == 1) or (player == "剪刀" and computer == 2) or (player == "石头" and computer == 0):
        print("玩家获胜")
        x+=1
    elif (player != "剪刀") and (player != "石头") and (player != "布"):
        print("请出’剪刀‘或’石头‘或’布‘\n")
    elif (player == "剪刀" and computer == 0) or (player == "石头" and computer == 1) or (player == "布" and computer == 2):
        print("平局")
    else:
        print("电脑获胜")
        y+=1
    if computer == 0:
        print("电脑出的是剪刀\n")
    elif computer == 1:
        print("电脑出的是石头\n")
    else:
        print("电脑出的是布\n")
    i += 1
print(f'最终比分是:\n\t{x}:{y}')
if x>y:
    print("\t玩家胜利！")
elif x<y:
    print('\t电脑胜利！')
else:
    print('\t平局！')